/*
 * Copyright (c) 2025, 大连理工大学 (Dalian University of Technology)
 *
 * Licensed under the Mulan PSL v2.
 * You can use this file according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of the License at
 *
 *     http://license.coscl.org.cn/MulanPSL2
 *
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. SEE THE MULAN PSL v2
 * FOR MORE DETAILS.
 */

#pragma once
#include "highfive/H5File.hpp"

#include "DBManager/IRepository/Result/ElementalStrain/IPYRAStrainRepository.h"
#include "DBManager/Repository/HDF5/Base/ResultRepositoryBase.h"

template <>
inline HighFive::DataType HighFive::create_datatype<SG::DataStructure::Post::PYRAStrainData> ()
{
    HighFive::CompoundType ct = { { "EID", HighFive::create_datatype<SG::DataStructure::Common::Id> () },
                                  { "CID", HighFive::create_datatype<SG::DataStructure::Common::Id> () },
                                  { "CTYPE", HighFive::create_datatype<char[4]> (), 1, true },
                                  { "NODEF", HighFive::create_datatype<SG::DataStructure::Common::I64> () },
                                  { "GRID", HighFive::create_datatype<SG::DataStructure::Common::Id[6]> (), 8, true },
                                  { "X", HighFive::create_datatype<SG::DataStructure::Common::Real[6]> (), 8, true },
                                  { "Y", HighFive::create_datatype<SG::DataStructure::Common::Real[6]> (), 8, true },
                                  { "Z", HighFive::create_datatype<SG::DataStructure::Common::Real[6]> (), 8, true },
                                  { "TXY", HighFive::create_datatype<SG::DataStructure::Common::Real[6]> (), 8, true },
                                  { "TYZ", HighFive::create_datatype<SG::DataStructure::Common::Real[6]> (), 8, true },
                                  { "TZX", HighFive::create_datatype<SG::DataStructure::Common::Real[6]> (), 8, true },
                                  { "DOMAIN_ID", HighFive::create_datatype<SG::DataStructure::Common::Id> () } };
    return ct;
}

SG_DBMANAGER_HDF5_NAMESPACE_OPEN
class PYRAStrainRepository : public IPYRAStrainRepository,
                             public SG::DBManager::HDF5::ResultRepositoryBase<SG::DataStructure::Post::PYRAStrainData>
{
  public:
    PYRAStrainRepository (SG::DBManager::HDF5Database& database);

    /**
     * @brief 初始化数据表的信息。
     */
    virtual void InitialDatasetInfo () override;
};
SG_DBMANAGER_HDF5_NAMESPACE_CLOSE
